<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
<title>Macros</title>
<meta name="generator" content="DocBook XSL Stylesheets V1.72.0">
<link rel="start" href="index.html" title="Liboil Reference Manual">
<link rel="up" href="ch02.html" title="Liboil Unstable API">
<link rel="prev" href="liboil-liboiltypes.html" title="liboiltypes">
<link rel="next" href="liboil-liboiljunk.html" title="liboiljunk">
<meta name="generator" content="GTK-Doc V1.8 (XML mode)">
<link rel="stylesheet" href="style.css" type="text/css">
<link rel="chapter" href="ch01.html" title="Liboil Stable API">
<link rel="chapter" href="ch02.html" title="Liboil Unstable API">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table class="navigation" id="top" width="100%" summary="Navigation header" cellpadding="2" cellspacing="2">
<tr valign="middle">
<td><a accesskey="p" href="liboil-liboiltypes.html"><img src="left.png" width="24" height="24" border="0" alt="Prev"></a></td>
<td><a accesskey="u" href="ch02.html"><img src="up.png" width="24" height="24" border="0" alt="Up"></a></td>
<td><a accesskey="h" href="index.html"><img src="home.png" width="24" height="24" border="0" alt="Home"></a></td>
<th width="100%" align="center">Liboil Reference Manual</th>
<td><a accesskey="n" href="liboil-liboiljunk.html"><img src="right.png" width="24" height="24" border="0" alt="Next"></a></td>
</tr>
<tr><td colspan="5" class="shortcuts"><nobr><a href="#id2561354" class="shortcut">Top</a>
                  &#160;|&#160;
                  <a href="#id2662126" class="shortcut">Description</a></nobr></td></tr>
</table>
<div class="refentry" lang="en">
<a name="liboil-liboilmacros"></a><div class="titlepage"></div>
<div class="refnamediv"><table width="100%"><tr>
<td valign="top">
<h2>
<a name="id2561354"></a><span class="refentrytitle">Macros</span>
</h2>
<p>Macros &#8212; Macros</p>
</td>
<td valign="top" align="right"></td>
</tr></table></div>
<div class="refsynopsisdiv">
<h2>Synopsis</h2>
<pre class="synopsis">



#define             <a href="liboil-liboilmacros.html#oil-min">oil_min</a>                             (x,y)
#define             <a href="liboil-liboilmacros.html#oil-max">oil_max</a>                             (x,y)
#define             <a href="liboil-liboilmacros.html#oil-divide-255">oil_divide_255</a>                      (x)
#define             <a href="liboil-liboilmacros.html#oil-argb">oil_argb</a>                            (a,r,g,b)
#define             <a href="liboil-liboilmacros.html#oil-argb-noclamp">oil_argb_noclamp</a>                    (a,r,g,b)
#define             <a href="liboil-liboilmacros.html#oil-argb-A">oil_argb_A</a>                          (color)
#define             <a href="liboil-liboilmacros.html#oil-argb-G">oil_argb_G</a>                          (color)
#define             <a href="liboil-liboilmacros.html#oil-argb-B">oil_argb_B</a>                          (color)
#define             <a href="liboil-liboilmacros.html#oil-argb-R">oil_argb_R</a>                          (color)
#define             <a href="liboil-liboilmacros.html#oil-muldiv-255">oil_muldiv_255</a>                      (a,b)
#define             <a href="liboil-liboilmacros.html#oil-clamp-255">oil_clamp_255</a>                       (x)
#define             <a href="liboil-liboilmacros.html#OIL-GET:CAPS">OIL_GET</a>                             (ptr, offset, type)
#define             <a href="liboil-liboilmacros.html#OIL-OFFSET:CAPS">OIL_OFFSET</a>                          (ptr, offset)
#define             <a href="liboil-liboilmacros.html#OIL-INCREMENT:CAPS">OIL_INCREMENT</a>                       (ptr, offset)
</pre>
</div>
<div class="refsect1" lang="en">
<a name="id2662126"></a><h2>Description</h2>
<p>
</p>
<p>

</p>
</div>
<div class="refsect1" lang="en">
<a name="id2662146"></a><h2>Details</h2>
<div class="refsect2" lang="en">
<a name="id2662157"></a><h3>
<a name="oil-min"></a>oil_min()</h3>
<a class="indexterm" name="id2662169"></a><pre class="programlisting">#define oil_min(x,y) ((x)&lt;(y)?(x):(y))
</pre>
<p>
Evaluates to the minimum of <em class="parameter"><code>x</code></em> and <em class="parameter"><code>y</code></em>.</p>
<p>

</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><span class="term"><em class="parameter"><code>x</code></em>&#160;:</span></td>
<td> a value
</td>
</tr>
<tr>
<td><span class="term"><em class="parameter"><code>y</code></em>&#160;:</span></td>
<td> a value
</td>
</tr>
</tbody>
</table></div>
</div>
<hr>
<div class="refsect2" lang="en">
<a name="id2586001"></a><h3>
<a name="oil-max"></a>oil_max()</h3>
<a class="indexterm" name="id2586013"></a><pre class="programlisting">#define oil_max(x,y) ((x)&gt;(y)?(x):(y))
</pre>
<p>
Evaluates to the maximum of <em class="parameter"><code>x</code></em> and <em class="parameter"><code>y</code></em>.</p>
<p>

</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><span class="term"><em class="parameter"><code>x</code></em>&#160;:</span></td>
<td> a value
</td>
</tr>
<tr>
<td><span class="term"><em class="parameter"><code>y</code></em>&#160;:</span></td>
<td> a value
</td>
</tr>
</tbody>
</table></div>
</div>
<hr>
<div class="refsect2" lang="en">
<a name="id2586077"></a><h3>
<a name="oil-divide-255"></a>oil_divide_255()</h3>
<a class="indexterm" name="id2586089"></a><pre class="programlisting">#define oil_divide_255(x) ((((x)+128) + (((x)+128)&gt;&gt;8))&gt;&gt;8)
</pre>
<p>
Divides <em class="parameter"><code>x</code></em> by 255 in a way that is compatible with the pixel
operations in Liboil.  The number 65025 is 255*255.
</p>
<p>
Evaluates to <em class="parameter"><code>x</code></em> divided by 255.</p>
<p>

</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody><tr>
<td><span class="term"><em class="parameter"><code>x</code></em>&#160;:</span></td>
<td> a value in the range [0,65025]
</td>
</tr></tbody>
</table></div>
</div>
<hr>
<div class="refsect2" lang="en">
<a name="id2664482"></a><h3>
<a name="oil-argb"></a>oil_argb()</h3>
<a class="indexterm" name="id2664494"></a><pre class="programlisting">#define             oil_argb(a,r,g,b)</pre>
<p>
Creates a Liboil ARGB value from individual components.  Clamps
each component to [0,255].
</p>
<p>
Evaluates to the ARGB value</p>
<p>

</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><span class="term"><em class="parameter"><code>a</code></em>&#160;:</span></td>
<td> alpha component
</td>
</tr>
<tr>
<td><span class="term"><em class="parameter"><code>r</code></em>&#160;:</span></td>
<td> red component
</td>
</tr>
<tr>
<td><span class="term"><em class="parameter"><code>g</code></em>&#160;:</span></td>
<td> green component
</td>
</tr>
<tr>
<td><span class="term"><em class="parameter"><code>b</code></em>&#160;:</span></td>
<td> blue component
</td>
</tr>
</tbody>
</table></div>
</div>
<hr>
<div class="refsect2" lang="en">
<a name="id2664581"></a><h3>
<a name="oil-argb-noclamp"></a>oil_argb_noclamp()</h3>
<a class="indexterm" name="id2664593"></a><pre class="programlisting">#define             oil_argb_noclamp(a,r,g,b)</pre>
<p>
Creates a Liboil ARGB value from individual components.  Does not
clamp components.
</p>
<p>
Evaluates to the ARGB value</p>
<p>

</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><span class="term"><em class="parameter"><code>a</code></em>&#160;:</span></td>
<td> alpha component
</td>
</tr>
<tr>
<td><span class="term"><em class="parameter"><code>r</code></em>&#160;:</span></td>
<td> red component
</td>
</tr>
<tr>
<td><span class="term"><em class="parameter"><code>g</code></em>&#160;:</span></td>
<td> green component
</td>
</tr>
<tr>
<td><span class="term"><em class="parameter"><code>b</code></em>&#160;:</span></td>
<td> blue component
</td>
</tr>
</tbody>
</table></div>
</div>
<hr>
<div class="refsect2" lang="en">
<a name="id2664680"></a><h3>
<a name="oil-argb-A"></a>oil_argb_A()</h3>
<a class="indexterm" name="id2664692"></a><pre class="programlisting">#define oil_argb_A(color) (((color)&gt;&gt;24)&amp;0xff)
</pre>
<p>
Extracts the alpha component from <em class="parameter"><code>color</code></em>.
</p>
<p>
Evaluates to the alpha component</p>
<p>

</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody><tr>
<td><span class="term"><em class="parameter"><code>color</code></em>&#160;:</span></td>
<td> an ARGB value
</td>
</tr></tbody>
</table></div>
</div>
<hr>
<div class="refsect2" lang="en">
<a name="id2664009"></a><h3>
<a name="oil-argb-G"></a>oil_argb_G()</h3>
<a class="indexterm" name="id2664021"></a><pre class="programlisting">#define oil_argb_G(color) (((color)&gt;&gt;8)&amp;0xff)
</pre>
<p>
Extracts the green component from <em class="parameter"><code>color</code></em>.
</p>
<p>
Evaluates to the green component</p>
<p>

</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody><tr>
<td><span class="term"><em class="parameter"><code>color</code></em>&#160;:</span></td>
<td> an ARGB value
</td>
</tr></tbody>
</table></div>
</div>
<hr>
<div class="refsect2" lang="en">
<a name="id2664070"></a><h3>
<a name="oil-argb-B"></a>oil_argb_B()</h3>
<a class="indexterm" name="id2664082"></a><pre class="programlisting">#define oil_argb_B(color) (((color)&gt;&gt;0)&amp;0xff)
</pre>
<p>
Extracts the blue component from <em class="parameter"><code>color</code></em>.
</p>
<p>
Evaluates to the blue component</p>
<p>

</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody><tr>
<td><span class="term"><em class="parameter"><code>color</code></em>&#160;:</span></td>
<td> an ARGB value
</td>
</tr></tbody>
</table></div>
</div>
<hr>
<div class="refsect2" lang="en">
<a name="id2664130"></a><h3>
<a name="oil-argb-R"></a>oil_argb_R()</h3>
<a class="indexterm" name="id2664142"></a><pre class="programlisting">#define oil_argb_R(color) (((color)&gt;&gt;16)&amp;0xff)
</pre>
<p>
Extracts the red component from <em class="parameter"><code>color</code></em>.
</p>
<p>
Evaluates to the red component</p>
<p>

</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody><tr>
<td><span class="term"><em class="parameter"><code>color</code></em>&#160;:</span></td>
<td> an ARGB value
</td>
</tr></tbody>
</table></div>
</div>
<hr>
<div class="refsect2" lang="en">
<a name="id2664190"></a><h3>
<a name="oil-muldiv-255"></a>oil_muldiv_255()</h3>
<a class="indexterm" name="id2664203"></a><pre class="programlisting">#define oil_muldiv_255(a,b) oil_divide_255((a)*(b))
</pre>
<p>
Multiplies <em class="parameter"><code>a</code></em> and <em class="parameter"><code>b</code></em> and divides the result by 255 in a way that
is compatible with the pixel operations in Liboil.
</p>
<p>
Evaluates to the result.</p>
<p>

</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><span class="term"><em class="parameter"><code>a</code></em>&#160;:</span></td>
<td> a value in the range [0,255]
</td>
</tr>
<tr>
<td><span class="term"><em class="parameter"><code>b</code></em>&#160;:</span></td>
<td> a value in the range [0,255]
</td>
</tr>
</tbody>
</table></div>
</div>
<hr>
<div class="refsect2" lang="en">
<a name="id2662224"></a><h3>
<a name="oil-clamp-255"></a>oil_clamp_255()</h3>
<a class="indexterm" name="id2662236"></a><pre class="programlisting">#define oil_clamp_255(x) oil_max(0,oil_min((x),255))
</pre>
<p>
Clamps <em class="parameter"><code>x</code></em> to the range [0,255].
</p>
<p>
Evaluates to the clamped value.</p>
<p>

</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody><tr>
<td><span class="term"><em class="parameter"><code>x</code></em>&#160;:</span></td>
<td> a value
</td>
</tr></tbody>
</table></div>
</div>
<hr>
<div class="refsect2" lang="en">
<a name="id2662284"></a><h3>
<a name="OIL-GET:CAPS"></a>OIL_GET()</h3>
<a class="indexterm" name="id2662297"></a><pre class="programlisting">#define OIL_GET(ptr, offset, type) (*(type *)((uint8_t *)(ptr) + (offset)) )
</pre>
<p>
Offsets <em class="parameter"><code>ptr</code></em> by <em class="parameter"><code>offset</code></em> number of bytes, and dereferences it
as type <em class="parameter"><code>type</code></em>.  Note that the offset is in bytes, and not in
the size of the pointer type.</p>
<p>

</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><span class="term"><em class="parameter"><code>ptr</code></em>&#160;:</span></td>
<td>
</td>
</tr>
<tr>
<td><span class="term"><em class="parameter"><code>offset</code></em>&#160;:</span></td>
<td>
</td>
</tr>
<tr>
<td><span class="term"><em class="parameter"><code>type</code></em>&#160;:</span></td>
<td>
</td>
</tr>
</tbody>
</table></div>
</div>
<hr>
<div class="refsect2" lang="en">
<a name="id2662385"></a><h3>
<a name="OIL-OFFSET:CAPS"></a>OIL_OFFSET()</h3>
<a class="indexterm" name="id2662397"></a><pre class="programlisting">#define OIL_OFFSET(ptr, offset) ((void *)((uint8_t *)(ptr) + (offset)) )
</pre>
<p>
Add <em class="parameter"><code>offset</code></em> bytes to the pointer <em class="parameter"><code>ptr</code></em>.</p>
<p>

</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><span class="term"><em class="parameter"><code>ptr</code></em>&#160;:</span></td>
<td>
</td>
</tr>
<tr>
<td><span class="term"><em class="parameter"><code>offset</code></em>&#160;:</span></td>
<td>
</td>
</tr>
</tbody>
</table></div>
</div>
<hr>
<div class="refsect2" lang="en">
<a name="id2662462"></a><h3>
<a name="OIL-INCREMENT:CAPS"></a>OIL_INCREMENT()</h3>
<a class="indexterm" name="id2662475"></a><pre class="programlisting">#define OIL_INCREMENT(ptr, offset) (ptr = (void *)((uint8_t *)ptr + (offset)) )
</pre>
<p>
Increments the pointer <em class="parameter"><code>ptr</code></em> by <em class="parameter"><code>offset</code></em> number of bytes.</p>
<p>

</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><span class="term"><em class="parameter"><code>ptr</code></em>&#160;:</span></td>
<td>
</td>
</tr>
<tr>
<td><span class="term"><em class="parameter"><code>offset</code></em>&#160;:</span></td>
<td>
</td>
</tr>
</tbody>
</table></div>
</div>
</div>
</div>
</body>
</html>
